package com.car.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class RelateUtil {

	/**
	 * unique 对应品牌车系集合
	 */
	public static Map<String, ArrayList<Integer>> unique_keys = null;
	public static Map<Integer, ArrayList<String>> brand_unique = null;
	public static Map<Integer, ArrayList<String>> brand_keyword = null;

	public RelateUtil() {
		brand_keyword = new HashMap<Integer, ArrayList<String>>();
		unique_keys = new HashMap<String, ArrayList<Integer>>();
		brand_unique = new HashMap<Integer, ArrayList<String>>();
	}

	public synchronized void AddSerial(String unique, Integer serial) {
		try {
			if (!unique.equals("0")) {
				ArrayList<Integer> list = unique_keys.get(unique);
				if (list == null) {
					list = new ArrayList<Integer>();
					list.add(serial);
					unique_keys.put(unique, list);
				} else if (!list.contains(serial)) {
					list.add(serial);
					unique_keys.put(unique, list);
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public synchronized void Addunique(String unique, Integer serial) {
		try {
			if (!unique.equals("0")) {
				ArrayList<String> list = brand_unique.get(serial);
				if (list == null) {
					list = new ArrayList<String>();
				}
				list.add(unique);
				brand_unique.put(serial, list);
				// System.out.println(brand_unique);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public synchronized void Addkeyword(String keyword, Integer serial) {
		try {
			ArrayList<String> list = brand_keyword.get(serial);
			if (list == null) {
				list = new ArrayList<String>();
			}
			list.add(keyword);
			brand_keyword.put(serial, list);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
